package com.test0109;


import java.io.*;


public class Test04 {
    public static void main(String[] args) throws IOException {
        // (4)把d盘下的文件拷贝到e盘下
         copy("d:/a.txt","d:/b.txt");

//        FileReader fileReader = new FileReader("d:/a.txt");
//        BufferedReader bufferedReader = new BufferedReader(fileReader);
//
//
//        FileWriter fileWriter = new FileWriter("d:/b.txt",true);
//        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
//        String str ="";
//        while ((str=bufferedReader.readLine()) !=null) {
//            bufferedWriter.write(str);
//            bufferedWriter.newLine();
//        }
//        bufferedReader.close();
//        fileReader.close();
//        bufferedWriter.close();
//        fileWriter.close();
    }
    public static void copy(String src,String dest) throws IOException {
        FileReader fileReader = new FileReader(src);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        FileWriter fileWriter = new FileWriter(dest,true);
        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
        String str ="";
        while ((str=bufferedReader.readLine()) !=null) {
            bufferedWriter.write(str);
            bufferedWriter.newLine();
        }
        bufferedReader.close();
        fileReader.close();

        bufferedWriter.close();
        fileWriter.close();
    }
}
